package com.lemon.smartsafety.http.service;

import android.content.Context;

import com.lemon.android.http.LemonRequestParams;
import com.lemon.smartsafety.app.EventTag;
import com.lemon.smartsafety.app.IApplication;
import com.lemon.smartsafety.app.RefreshType;
import com.lemon.smartsafety.entity.safe.safe_manager.CompanySafeManageHistoryItemVo;
import com.lemon.smartsafety.http.UrlInfo;
import com.lemon.smartsafety.http.callback.HandlerCallback;
import com.lemon.smartsafety.utils.LogUtils;
import com.zhy.http.okhttp.OkHttpUtils;

import java.util.List;

/**
 * 项目名称：workspace
 * 类描述：
 * 创建人：Fargo
 * 创建时间：2016/6/7 14:40
 * 修改人：Fargo
 * 修改时间：2016/6/7 14:40
 * 修改备注：
 */
public class SafeManagerHistoryItemServices extends BaseHttpServices {

    private SafeManagerHistoryItemServices(Context context) {
        super(context);
    }

    public static SafeManagerHistoryItemServices init() {
        return new SafeManagerHistoryItemServices(IApplication.context());
    }


    /**
     * 获取安全管理设置的List
     *
     * @return
     */
    public SafeManagerHistoryItemServices getItemList(RefreshType type,String item_id, int pageSize, int currentPage) {
        LemonRequestParams params = new LemonRequestParams();
        params.put("item_id", item_id);
        params.put("current_page", currentPage);
        params.put("page_size", pageSize );
        LogUtils.LOGE("pageSize  ",String.valueOf(pageSize));
        return getItemList(type, params);
    }

    /**
     * 获取安全管理设置的List
     *
     * @param params
     * @return
     */
    private SafeManagerHistoryItemServices getItemList(RefreshType type, LemonRequestParams params) {
        HandlerCallback<List<CompanySafeManageHistoryItemVo>> callback = new HandlerCallback<List<CompanySafeManageHistoryItemVo>>(EventTag.TAG_SAFE_MANAGER_HISTORY) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.SAFE_MANAGER_HISTORY_LIST);
        OkHttpUtils.post().url(serverUrl).tag(callback.getTag()).params(params).build().execute(callback);
        return this;
    }






}
